package cn.ad.server.web.service;


import cn.ad.server.domain.ad.AdSpace;
import cn.ad.server.persistence.AdSpaceRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdspaceServiceIpml implements IAdspaceService {

	@Autowired
	private AdSpaceRepository adSpaceRepository;
	
	@Override
	public AdSpace findAdSpaceByID(long adSpaceId) throws ResourceNotFoundException {
		if(adSpaceId <= 0){
			throw new IllegalArgumentException("adSpaceId["+ adSpaceId +"] is illegal.");
		}
		AdSpace adSpace = adSpaceRepository.findAdSpaceById(adSpaceId);
		if (adSpace == null)
			throw new ResourceNotFoundException("Adspace", adSpaceId + "");
		return adSpace;
	}
}
